import express from 'express'
import React from 'react'
import { renderToString } from 'react-dom/server'
import { StaticRouter } from 'react-router-dom';
import Routes from '../containers/Routes';

const app = express();
app.use(express.static('public/'))

const content = req =>`
<html>
      <head>
        
      </head>
      <body>
        <div id="root">${renderToString(<StaticRouter location={req.path}>{Routes}</StaticRouter>)}</div>
        <script src="/index.js"></script>
      </body>
    </html>`
app.get('*', (req, res) => {
    res.send(content(req));
}).listen(8085, e => {
    console.log('listen up');
})